import requests
from config.all_paths import config_variable_path
from utils.file_handling.txt_handling import read_txt
from utils.time_tool.time_control import Getdate

def push_message(webhook, message_content):
    # 发送报告
    requests.post(url=webhook, json=message_content, verify=False)


def parse_prometheus_data(file_path):
    # 获取测试报告的相关信息
    true = True
    content = eval(read_txt(file_path))
    return content


def generate_message_content_GZF(content, description, report_url):
    # 构建推送至飞书的报告的样式
    totalDoctor = content['totalDoctor']
    totalFg = content['totalFg']
    totalFgIssue = content['totalFgIssue']
    totalFgVerification = content['totalFgVerification']
    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"
                    f"绑定医生数量：{totalDoctor}\n"
                    f"非公权益数量：{totalFg}\n"
                    f"非公权益发放数量：{totalFgIssue}\n"
                    f"非公权益核销数量：{totalFgVerification}\n"

        }
    }
    return message_content

def generate_message_content_SIP(content, description, report_url):
    # sip外呼数据统计
    # 构建推送至飞书的报告的样式
    # 总数
    total_all = content['totalSip']['total_all']
    Successfully_connected = content['totalSip']['Successfully_connected']
    no_answer = content['totalSip']['no_answer']
    interrupt_call = content['totalSip']['interrupt_call']
    call_failure = content['totalSip']['call_failure']

    # 长春
    changchun_total_all = content['areaSip']['changchu']['total_all']
    changchun_Successfully_connected = content['areaSip']['changchu']['Successfully_connected']
    changchun_no_answer = content['areaSip']['changchu']['no_answer']
    changchun_interrupt_call = content['areaSip']['changchu']['interrupt_call']
    changchun_call_failure = content['areaSip']['changchu']['call_failure']

    # 广州
    guangzhou_total_all = content['areaSip']['guangzhou']['total_all']
    guangzhou_Successfully_connected = content['areaSip']['guangzhou']['Successfully_connected']
    guangzhou_no_answer = content['areaSip']['guangzhou']['no_answer']
    guangzhou_interrupt_call = content['areaSip']['guangzhou']['interrupt_call']
    guangzhou_call_failure = content['areaSip']['guangzhou']['call_failure']

    # 成都
    chengdu_total_all = content['areaSip']['chengdu']['total_all']
    chengdu_Successfully_connected = content['areaSip']['chengdu']['Successfully_connected']
    chengdu_no_answer = content['areaSip']['chengdu']['no_answer']
    chengdu_interrupt_call = content['areaSip']['chengdu']['interrupt_call']
    chengdu_call_failure = content['areaSip']['chengdu']['call_failure']

    # 合肥
    hefei_total_all = content['areaSip']['hefei']['total_all']
    hefei_Successfully_connected = content['areaSip']['hefei']['Successfully_connected']
    hefei_no_answer = content['areaSip']['hefei']['no_answer']
    hefei_interrupt_call = content['areaSip']['hefei']['interrupt_call']
    hefei_call_failure = content['areaSip']['hefei']['call_failure']

    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"
                    
                    f"所有片区---------------\n"
                    f"外呼总量：{total_all}\n"
                    f"接通成功总量：{Successfully_connected}\n"
                    f"无人应答总量：{no_answer}\n"
                    f"中断呼叫总量：{interrupt_call}\n"
                    f"呼叫失败总量：{call_failure}\n"
                    f"成功率：{calculate_percentage(Successfully_connected, total_all)}\n"
                    
                    f"长春---------------\n"
                    f"外呼总量：{changchun_total_all}\n"
                    f"接通成功总量：{changchun_Successfully_connected}\n"
                    f"无人应答总量：{changchun_no_answer}\n"
                    f"中断呼叫总量：{changchun_interrupt_call}\n"
                    f"呼叫失败总量：{changchun_call_failure}\n"
                    f"成功率：{calculate_percentage(changchun_Successfully_connected, changchun_total_all)}\n"
                    
                    f"广州---------------\n"
                    f"外呼总量：{guangzhou_total_all}\n"
                    f"接通成功总量：{guangzhou_Successfully_connected}\n"
                    f"无人应答总量：{guangzhou_no_answer}\n"
                    f"中断呼叫总量：{guangzhou_interrupt_call}\n"
                    f"呼叫失败总量：{guangzhou_call_failure}\n"
                    f"成功率：{calculate_percentage(guangzhou_Successfully_connected, guangzhou_total_all)}\n"
                    
                    f"成都---------------\n"
                    f"外呼总量：{chengdu_total_all}\n"
                    f"接通成功总量：{chengdu_Successfully_connected}\n"
                    f"无人应答总量：{chengdu_no_answer}\n"
                    f"中断呼叫总量：{chengdu_interrupt_call}\n"
                    f"呼叫失败总量：{chengdu_call_failure}\n"
                    f"成功率：{calculate_percentage(chengdu_Successfully_connected, chengdu_total_all)}\n"
                    
                    f"合肥---------------\n"
                    f"外呼总量：{hefei_total_all}\n"
                    f"接通成功总量：{hefei_Successfully_connected}\n"
                    f"无人应答总量：{hefei_no_answer}\n"
                    f"中断呼叫总量：{hefei_interrupt_call}\n"
                    f"呼叫失败总量：{hefei_call_failure}\n"
                    f"成功率：{calculate_percentage(hefei_Successfully_connected, hefei_total_all)}\n"
        }
    }
    return message_content

def calculate_percentage(a, b):
    # 计算百分比
    if int(b) != 0:  # 防止除以零的错误
        percentage = (int(a) / int(b)) * 100
        return f"{percentage:.2f}%"
    else:
        return f"-%"


def generate_message_content_XCXSIP(content, description, report_url):
    # 构建推送至飞书的报告的样式
    # 外呼
    total_all = content['outbound_call']['total_all']
    Successfully_connected = content['outbound_call']['Successfully_connected']
    no_answer = content['outbound_call']['no_answer']
    interrupt_call = content['outbound_call']['interrupt_call']
    call_failure = content['outbound_call']['call_failure']

    # 回拨
    callback_total_all = content['callback']['total_all']
    callback_Successfully_connected = content['callback']['Successfully_connected']
    callback_no_answer = content['callback']['no_answer']
    callback_interrupt_call = content['callback']['interrupt_call']
    callback_call_failure = content['callback']['call_failure']


    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"

                    f"外呼---------------\n"
                    f"外呼总量：{total_all}\n"
                    f"接通成功总量：{Successfully_connected}\n"
                    f"无人应答总量：{no_answer}\n"
                    f"中断呼叫总量：{interrupt_call}\n"
                    f"呼叫失败总量：{call_failure}\n"

                    f"回拨---------------\n"
                    f"回拨总量：{callback_total_all}\n"
                    f"接通成功总量：{callback_Successfully_connected}\n"
                    f"无人应答总量：{callback_no_answer}\n"
                    f"中断呼叫总量：{callback_interrupt_call}\n"
                    f"呼叫失败总量：{callback_call_failure}\n"
        }
    }
    return message_content


def generate_message_content_JZ(content, description, report_url):

    # 构建减重工作台推送至飞书的报告的样式

    newRegisteredCustomerNum = content['newRegisteredCustomerNum']
    inServiceCustomerNum = content['inServiceCustomerNum']
    endedServiceCustomerNum = content['endedServiceCustomerNum']
    totalCustomerNum = content['totalCustomerNum']
    todayClueNum = content['todayClueNum']
    toAllocateClueNum = content['toAllocateClueNum']
    invalidClueNum = content['invalidClueNum']
    totalClueNum = content['totalClueNum']
    noNeedNutritionistClueNum = content['noNeedNutritionistClueNum']
    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"
                    f"注册客户数：{newRegisteredCustomerNum}\n"
                    f"服务中客户数：{inServiceCustomerNum}\n"
                    f"已结束客户数：{endedServiceCustomerNum}\n"
                    f"订单客户数：{totalCustomerNum}\n"
                    f"今日新增订单数：{todayClueNum}\n"
                    f"待分配订单数：{toAllocateClueNum}\n"
                    f"无效订单数：{invalidClueNum}\n"
                    f"总订单数：{totalClueNum}\n"
                    f"无需营养师订单数：{noNeedNutritionistClueNum}\n"
        }
    }
    return message_content



def generate_message_content_FG(content, description, report_url):

    # 构建非公推送至飞书的报告的样式

    totalCount = content['totalCount']
    childCount = content['childCount']
    totalPaid = content['totalPaid']
    runningCount = content['runningCount']
    endedCount = content['endedCount']
    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"
                    f"权益包开卡数：{totalCount}\n"
                    f"权益包开卡人数：{childCount}\n"
                    f"开卡总金额：{totalPaid}\n"
                    f"订单客户数：{runningCount}\n"
                    f"权益包已完结数：{endedCount}\n"
        }
    }
    return message_content

def generate_message_content_CZKB(content, description, report_url):

    # 构建非公推送至飞书的报告的样式

    visitCount = content['visitCount']
    fullVisitCount = content['fullVisitCount']
    isVisitCount = content['isVisitCount']
    visit7P10Count = content['visit7P10Count']
    visit7P25Count = content['visit7P25Count']
    importCount = content['importCount']
    childVisitCount = content['childVisitCount']
    importRate = content['importRate']
    importNumCount = content['importNumCount']
    visitNumCount = content['visitNumCount']
    importNumCountDistinct = content['importNumCountDistinct']
    visitNumCountDistinct = content['visitNumCountDistinct']

    #外呼相关
    callCompletingCount =content['callCompletingCount'] #虚拟外呼拨通量
    callCount = content['callCount'] #虚拟外呼拨号量
    callCompletingRate = content['callCompletingRate'] #接通率
    callValidCompletingCount = content['callValidCompletingCount'] #虚拟外呼有效拨通量
    callValidCompletingAccountCount = content['callValidCompletingAccountCount'] #虚拟外呼有效拨通用户量

    #检查项
    full = content['full']
    heightWeight = content['heightWeight']
    boneage = content['boneage']
    stimulateExperiment = content['stimulateExperiment']
    bloodFullSet = content['bloodFullSet']
    mri = content['mri']
    geneticExamination = content['geneticExamination']
    bultrasound = content['bultrasound']
    tcmRelated = content['tcmRelated']
    ankle = content['ankle']
    bodyAnalysis = content['bodyAnalysis']
    boneDensity = content['boneDensity']
    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"
                    f"标记回访量：{visitCount}\n"
                    f"近7天回访≤P10数：{visit7P10Count}\n"
                    f"近7天回访≤P25数：{visit7P25Count}\n"
                    f"完整回访量：{fullVisitCount}\n"
                    f"跟进记录量：{childVisitCount}\n"

                    f"导诊量：{importCount}\n"
                    f"导诊次：{importNumCount}\n"
                    f"导诊次(宝宝去重)：{importNumCountDistinct}\n"
                    f"导诊率：{format_round(importRate)}\n"

                    f"标记到诊量：{isVisitCount}\n"
                    f"标记到诊次：{visitNumCount}\n"
                    f"标记到诊次(宝宝去重)：{visitNumCountDistinct}\n"

                    f"虚拟外呼拨通量：{callCompletingCount}\n"
                    f"虚拟外呼拨号量：{callCount}\n"
                    f"接通率：{format_round(callCompletingRate)}\n"
                    f"虚拟外呼有效拨通量：{callValidCompletingCount}\n"
                    f"虚拟外呼有效拨通用户量：{callValidCompletingAccountCount}\n"
                    
                    #检查项
                    f"全套检查宝宝量：{full}\n"
                    f"身高体重：{heightWeight}\n"
                    f"骨龄：{boneage}\n"
                    f"激发试验：{stimulateExperiment}\n"
                    f"血全套：{bloodFullSet}\n"
                    
                    f"MRI：{mri}\n"
                    f"基因检查：{geneticExamination}\n"
                    f"B超：{bultrasound}\n"
                    f"中医相关：{tcmRelated}\n"

                    f"足踝：{ankle}\n"
                    f"身体成分分析：{bodyAnalysis}\n"
                    f"骨密度：{boneDensity}\n"
        }
    }
    return message_content


# 环比数值语义化转换
def format_percent_change(value_str):
    try:
        value = float(value_str)
        if value > 0:
            return f"增加{abs(value):.0f}%"
        elif value < 0:
            return f"减少{abs(value):.0f}%"
        else:
            return "持平"
    except ValueError:
        return "数据异常"


# 金额单位追加
def format_currency(value_str):
    return f"{value_str}元" if value_str else "0元"


# 续费率百分比转换
def format_rate(value_str):
    try:
        return f"{float(value_str) * 100:.0f}%"
    except ValueError:
        return "数据异常"

#保留两位小数
def format_round(value_str):
    try:
        return f"{(round(float(value_str),2))}%"
    except ValueError:
        return "数据异常"

def generate_message_content_JZKB(content, description, report_url):

    # 构建减重看板推送至飞书的报告的样式
    # 服务数据
    freshTime = content['freshTime']    # 数据截止时间
    assignCount = content['assignCount']    # 已分配订单数
    claimedCount = content['claimedCount']  # 已认领订单数
    unClaimedCount = content['unClaimedCount']  # 未认领订单数
    invalidCount = content['invalidCount']  # 无效订单数
    recentSevenEndCount = content['recentSevenEndCount']    # 最近7天结束订单数
    noOpenCustomerCount = content['noOpenCustomerCount']     # 未开启客户数
    waitServiceCustomerCount = content['waitServiceCustomerCount']   # 待服务客户数
    serviceCustomerCount = content['serviceCustomerCount']   # 服务中客户数
    servicePauseCustomerCount = content['servicePauseCustomerCount']  # 服务暂停客户数
    serviceEndCustomerCount = content['serviceEndCustomerCount']  # 服务结束客户数

    # 人群数据

    activeUserCount = content['activeUserCount']  # 日活总人数
    normalUserClockCount = content['normalUserClockCount']  # 正餐打卡总人数
    normalUserAvgCount = content['normalUserAvgCount']  # 日均正餐打卡人数
    normalClockTotalCount = content['normalClockTotalCount']  # 正餐打卡总次数
    normalClockAvgCount = content['normalClockAvgCount']  # 日均正餐打卡次数
    sportUserCount = content['sportUserCount']  # 运动打卡总人数
    sportUserAvgCount = content['sportUserAvgCount']  # 日均运动打卡人数
    sportClockTotalCount = content['sportClockTotalCount']  # 运动打卡总次数
    sportClockAvgCount = content['sportClockAvgCount']  # 日均运动打卡次数

    # 业绩数据
    actualOrderCount = content['actualOrderCount']  # 实付订单数
    actualOrderCountPercent = content['actualOrderCountPercent']  # 实付订单数环比上月
    actualPayTotal = content['actualPayTotal']  # 实付总金额
    actualPayTotalPercent = content['actualPayTotalPercent']  # 实付总金额环比上月
    firstOrderCount = content['firstOrderCount']  # 首单数
    firstOrderCountPercent = content['firstOrderCountPercent']  # 首单数环比上月
    firstPayTotal = content['firstPayTotal']  # 首单总金额
    firstPayTotalPercent = content['firstPayTotalPercent']  # 首单总金额环比上月
    newOrderCount = content['newOrderCount']  # 新续数
    newOrderCountPercent = content['newOrderCountPercent']  # 新续数环比上月
    newPayTotal = content['newPayTotal']  # 新续总金额
    newPayTotalPercent = content['newPayTotalPercent']  # 新续总金额环比上月
    newRenewRate = content['newRenewRate']  # 新续率
    oldOrderCount = content['oldOrderCount']  # 老续数
    oldOrderCountPercent = content['oldOrderCountPercent']  # 老续数环比上月
    oldPayTotal = content['oldPayTotal']  # 老续总金额
    oldPayTotalPercent = content['oldPayTotalPercent']  # 老续总金额环比上月
    oldRenewRate = content['oldRenewRate']  # 老续率

    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n日期：{Getdate().getCurrentday()} {Getdate().getWeekdayToday()}\n"
                    f"项目描述：{description}\n"
                    f"减重数据看板-------服务数据\n"
                    f"数据截止时间：{freshTime}\n"
                    f"已分配订单数：{assignCount}\n"
                    f"已认领订单数：{claimedCount}\n"
                    f"未认领订单数：{unClaimedCount}\n"
                    f"无效订单数：{invalidCount}\n"
                    f"最近7天结束订单数：{recentSevenEndCount}\n"
                    f"未开启客户数：{noOpenCustomerCount}\n"
                    f"待服务客户数：{waitServiceCustomerCount}\n"
                    f"服务中客户数：{serviceCustomerCount}\n"
                    f"服务暂停客户数：{servicePauseCustomerCount}\n"
                    f"服务结束客户数：{serviceEndCustomerCount}\n\n"
                    
                    
                    f"减重数据看板-------人群数据\n"
                    f"日活总人数：{activeUserCount}\n"
                    f"正餐打卡总人数：{normalUserClockCount}\n"
                    f"日均正餐打卡人数：{normalUserAvgCount}\n"
                    f"正餐打卡总次数：{normalClockTotalCount}\n"
                    f"日均正餐打卡次数：{normalClockAvgCount}\n"
                    f"运动打卡总人数：{sportUserCount}\n"
                    f"日均运动打卡人数：{sportUserAvgCount}\n"
                    f"运动打卡总次数：{sportClockTotalCount}\n"
                    f"日均运动打卡次数：{sportClockAvgCount}\n\n"


                    f"减重数据看板-------业绩数据\n"
                    f"实付订单数：{actualOrderCount}\n"
                    f"实付订单数环比上月：{format_percent_change(actualOrderCountPercent)}\n"
                    f"实付总金额：{format_currency(actualPayTotal)}\n"
                    f"实付总金额环比上月：{format_percent_change(actualPayTotalPercent)}\n"
                    f"首单数：{firstOrderCount}\n"
                    f"首单数环比上月：{format_percent_change(firstOrderCountPercent)}\n"
                    f"首单总金额：{format_currency(firstPayTotal)}\n"
                    f"首单总金额环比上月：{format_percent_change(firstPayTotalPercent)}\n"
                    f"新续数：{newOrderCount}\n"
                    f"新续数环比上月：{format_percent_change(newOrderCountPercent)}\n"
                    f"新续总金额：{format_currency(newPayTotal)}\n"
                    f"新续总金额环比上月：{format_percent_change(newPayTotalPercent)}\n"
                    f"新续率：{format_rate(newRenewRate)}\n"
                    f"老续数：{oldOrderCount}\n"
                    f"老续数环比上月：{format_percent_change(oldOrderCountPercent)}\n"
                    f"老续总金额：{format_currency(oldPayTotal)}\n"
                    f"老续总金额环比上月：{format_percent_change(oldPayTotalPercent)}\n"
                    f"老续率：{format_rate(oldRenewRate)}\n"


                                                               }
    }
    return message_content


def generate_message_content_YSDS(content, description, report_url):
    # 医师大赛的数据统计
    # 构建推送至飞书的报告的样式

    # 昨日新增数据
    yesterday_numberEntries = content['yesterdayData']['numberEntries']
    yesterday_numberParticipants = content['yesterdayData']['numberParticipants']
    yesterday_unreviewedEntries = content['yesterdayData']['unreviewedEntries']
    yesterday_entriesNotPassingPreliminaryReview = content['yesterdayData']['entriesNotPassingPreliminaryReview']
    yesterday_entriesPassingPreliminaryReview = content['yesterdayData']['entriesPassingPreliminaryReview']
    yesterday_unreviewedForRe_review = content['yesterdayData']['unreviewedForRe-review']
    yesterday_entriesNotPassingRe_review = content['yesterdayData']['entriesNotPassingRe-review']
    yesterday_entriesPassingRe_review = content['yesterdayData']['entriesPassingRe-review']
    yesterday_unallocated = content['yesterdayData']['unallocated']
    yesterday_assigned = content['yesterdayData']['assigned']
    yesterday_re_reviewedButNotScored = content['yesterdayData']['re-reviewedButNotScored']
    yesterday_score_da80 = content['yesterdayData']['score≥80']
    yesterday_score_xiao80 = content['yesterdayData']['score<80']
    yesterday_invitationPending = content['yesterdayData']['invitationPending']
    yesterday_invited = content['yesterdayData']['invited']

    # 昨日及之前的所有数据
    yesterdayAndBefore_numberEntries = content['yesterdayAndBeforeData']['numberEntries']
    yesterdayAndBefore_numberParticipants = content['yesterdayAndBeforeData']['numberParticipants']
    yesterdayAndBefore_unreviewedEntries = content['yesterdayAndBeforeData']['unreviewedEntries']
    yesterdayAndBefore_entriesNotPassingPreliminaryReview = content['yesterdayAndBeforeData']['entriesNotPassingPreliminaryReview']
    yesterdayAndBefore_entriesPassingPreliminaryReview = content['yesterdayAndBeforeData']['entriesPassingPreliminaryReview']
    yesterdayAndBefore_unreviewedForRe_review = content['yesterdayAndBeforeData']['unreviewedForRe-review']
    yesterdayAndBefore_entriesNotPassingRe_review = content['yesterdayAndBeforeData']['entriesNotPassingRe-review']
    yesterdayAndBefore_entriesPassingRe_review = content['yesterdayAndBeforeData']['entriesPassingRe-review']
    yesterdayAndBefore_unallocated = content['yesterdayAndBeforeData']['unallocated']
    yesterdayAndBefore_assigned = content['yesterdayAndBeforeData']['assigned']
    yesterdayAndBefore_re_reviewedButNotScored = content['yesterdayAndBeforeData']['re-reviewedButNotScored']
    yesterdayAndBefore_score_da80 = content['yesterdayAndBeforeData']['score≥80']
    yesterdayAndBefore_score_xiao80 = content['yesterdayAndBeforeData']['score<80']
    yesterdayAndBefore_invitationPending = content['yesterdayAndBeforeData']['invitationPending']
    yesterdayAndBefore_invited = content['yesterdayAndBeforeData']['invited']


    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n"
                    f"项目描述：{description}\n"
                    f"---------\n"
                    f"{Getdate().getYesterday()}当天新增数据\n"
                    f"参赛作品数量：{yesterday_numberEntries}\n"
                    f"参赛人数：{yesterday_numberParticipants}\n"
                    f"未初审：{yesterday_unreviewedEntries}\n"
                    f"初审拒绝：{yesterday_entriesNotPassingPreliminaryReview}\n"
                    f"初审通过：{yesterday_entriesPassingPreliminaryReview}\n"
                    f"未复审：{yesterday_unreviewedForRe_review}\n"
                    f"复审拒绝：{yesterday_entriesNotPassingRe_review}\n"
                    f"复审通过：{yesterday_entriesPassingRe_review}\n"
                    f"未分配：{yesterday_unallocated}\n"
                    f"已分配：{yesterday_assigned}\n"
                    f"未评分：{yesterday_re_reviewedButNotScored}\n"
                    f"评分>=80：{yesterday_score_da80}\n"
                    f"评分<80：{yesterday_score_xiao80}\n"
                    f"邀请中：{int(yesterday_invitationPending)-int(yesterday_invited)}\n"
                    f"已邀请：{yesterday_invited}\n"
                    f"---------\n"
                    f"{Getdate().getYesterday()}当天及之前数据\n"
                    f"参赛作品数量：{yesterdayAndBefore_numberEntries}\n"
                    f"参赛人数：{yesterdayAndBefore_numberParticipants}\n"
                    f"未初审：{yesterdayAndBefore_unreviewedEntries}\n"
                    f"初审拒绝：{yesterdayAndBefore_entriesNotPassingPreliminaryReview}\n"
                    f"初审通过：{yesterdayAndBefore_entriesPassingPreliminaryReview}\n"
                    f"未复审：{yesterdayAndBefore_unreviewedForRe_review}\n"
                    f"复审拒绝：{yesterdayAndBefore_entriesNotPassingRe_review}\n"
                    f"复审通过：{yesterdayAndBefore_entriesPassingRe_review}\n"
                    f"未分配：{yesterdayAndBefore_unallocated}\n"
                    f"已分配：{yesterdayAndBefore_assigned}\n"
                    f"未评分：{yesterdayAndBefore_re_reviewedButNotScored}\n"
                    f"评分>=80：{yesterdayAndBefore_score_da80}\n"
                    f"评分<80：{yesterdayAndBefore_score_xiao80}\n"
                    f"邀请中：{int(yesterdayAndBefore_invitationPending)-int(yesterdayAndBefore_invited)}\n"
                    f"已邀请：{yesterdayAndBefore_invited}\n"
        }
    }
    return message_content

def generate_message_content_YSDS_1(content, description, report_url):
    # 医师大赛的数据统计
    # 构建推送至飞书的报告的样式
    # 今日新增数据
    numberEntries = content['todayData']['numberEntries']
    numberParticipants = content['todayData']['numberParticipants']
    unreviewedEntries = content['todayData']['unreviewedEntries']
    entriesNotPassingPreliminaryReview = content['todayData']['entriesNotPassingPreliminaryReview']
    entriesPassingPreliminaryReview = content['todayData']['entriesPassingPreliminaryReview']
    unreviewedForRe_review = content['todayData']['unreviewedForRe-review']
    entriesNotPassingRe_review = content['todayData']['entriesNotPassingRe-review']
    entriesPassingRe_review = content['todayData']['entriesPassingRe-review']
    unallocated = content['todayData']['unallocated']
    assigned = content['todayData']['assigned']
    re_reviewedButNotScored = content['todayData']['re-reviewedButNotScored']
    score_da80 = content['todayData']['score≥80']
    score_xiao80 = content['todayData']['score<80']
    invitationPending = content['todayData']['invitationPending']
    invited = content['todayData']['invited']


    # 所有数据
    all_numberEntries = content['allData']['numberEntries']
    all_numberParticipants = content['allData']['numberParticipants']
    all_unreviewedEntries = content['allData']['unreviewedEntries']
    all_entriesNotPassingPreliminaryReview = content['allData']['entriesNotPassingPreliminaryReview']
    all_entriesPassingPreliminaryReview = content['allData']['entriesPassingPreliminaryReview']
    all_unreviewedForRe_review = content['allData']['unreviewedForRe-review']
    all_entriesNotPassingRe_review = content['allData']['entriesNotPassingRe-review']
    all_entriesPassingRe_review = content['allData']['entriesPassingRe-review']
    all_unallocated = content['allData']['unallocated']
    all_assigned = content['allData']['assigned']
    all_re_reviewedButNotScored = content['allData']['re-reviewedButNotScored']
    all_score_da80 = content['allData']['score≥80']
    all_score_xiao80 = content['allData']['score<80']
    all_invitationPending = content['allData']['invitationPending']
    all_invited = content['allData']['invited']

    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n"
                    f"项目描述：{description}\n"
                    f"---------\n"
                    f"{Getdate().getCurrentday()}当天新增数据\n"
                    f"参赛作品数量：{numberEntries}\n"
                    f"参赛人数：{numberParticipants}\n"
                    f"未初审：{unreviewedEntries}\n"
                    f"初审拒绝：{entriesNotPassingPreliminaryReview}\n"
                    f"初审通过：{entriesPassingPreliminaryReview}\n"
                    f"未复审：{unreviewedForRe_review}\n"
                    f"复审拒绝：{entriesNotPassingRe_review}\n"
                    f"复审通过：{entriesPassingRe_review}\n"
                    f"未分配：{unallocated}\n"
                    f"已分配：{assigned}\n"
                    f"未评分：{re_reviewedButNotScored}\n"
                    f"评分>=80：{score_da80}\n"
                    f"评分<80：{score_xiao80}\n"
                    f"邀请中：{int(invitationPending)-int(invited)}\n"
                    f"已邀请：{invited}\n"
                    f"---------\n"
                    f"{Getdate().getCurrentdayAll()}前数据\n"
                    f"参赛作品数量：{all_numberEntries}\n"
                    f"参赛人数：{all_numberParticipants}\n"
                    f"未初审：{all_unreviewedEntries}\n"
                    f"初审拒绝：{all_entriesNotPassingPreliminaryReview}\n"
                    f"初审通过：{all_entriesPassingPreliminaryReview}\n"
                    f"未复审：{all_unreviewedForRe_review}\n"
                    f"复审拒绝：{all_entriesNotPassingRe_review}\n"
                    f"复审通过：{all_entriesPassingRe_review}\n"
                    f"未分配：{all_unallocated}\n"
                    f"已分配：{all_assigned}\n"
                    f"未评分：{all_re_reviewedButNotScored}\n"
                    f"评分>=80：{all_score_da80}\n"
                    f"评分<80：{all_score_xiao80}\n"
                    f"邀请中：{int(all_invitationPending)-int(all_invited)}\n"
                    f"已邀请：{all_invited}\n"
        }
    }
    return message_content


def generate_message_content_AiRobot(content, description, report_url):
    '''
    AI小梧各系统的问答人数/问答次数
    数据统计为t-1
    维度为：t-1当日新增，t-1及其之前的所有数据
    '''
    # 字段命名
    wt_doctor_banner_chatNum = 0
    wt_doctor_banner_chatTimes = 0
    wt_patient_banner_chatNum = 0
    wt_patient_banner_chatTimes = 0
    wt_patient_suspend_chatNum = 0
    wt_patient_suspend_chatTimes = 0
    wt_official_chatNum = 0
    wt_official_chatTimes = 0
    wt_statistics_chatNum = 0
    wt_statistics_chatTimes = 0
    wt_sms_chatNum = 0
    wt_sms_chatTimes = 0
    wt_patient_home_suspend_chatNum = 0
    wt_patient_home_suspend_chatTimes = 0
    wt_patient_mine_suspend_chatNum = 0
    wt_patient_mine_suspend_chatTimes = 0
    wt_patient_evaluation_records_banner_chatNum = 0
    wt_patient_evaluation_records_banner_chatTimes = 0
    ehis_banner_chatNum = 0
    ehis_banner_chatTimes = 0
    other_chatNum = 0
    other_chatTimes = 0

    all_wt_doctor_banner_chatNum = 0
    all_wt_doctor_banner_chatTimes = 0
    all_wt_patient_banner_chatNum = 0
    all_wt_patient_banner_chatTimes = 0
    all_wt_patient_suspend_chatNum = 0
    all_wt_patient_suspend_chatTimes = 0
    all_wt_official_chatNum = 0
    all_wt_official_chatTimes = 0
    all_wt_statistics_chatNum = 0
    all_wt_statistics_chatTimes = 0
    all_wt_sms_chatNum = 0
    all_wt_sms_chatTimes = 0
    all_wt_patient_home_suspend_chatNum = 0
    all_wt_patient_home_suspend_chatTimes = 0
    all_wt_patient_mine_suspend_chatNum = 0
    all_wt_patient_mine_suspend_chatTimes = 0
    all_wt_patient_evaluation_records_banner_chatNum = 0
    all_wt_patient_evaluation_records_banner_chatTimes = 0
    all_ehis_banner_chatNum = 0
    all_ehis_banner_chatTimes = 0
    all_other_chatNum = 0
    all_other_chatTimes = 0

    yesterdayData = content['data']['chatInfo']
    for data in yesterdayData:
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_doctor_banner':
            wt_doctor_banner_chatNum = data['num']
            wt_doctor_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_banner':
            wt_patient_banner_chatNum = data['num']
            wt_patient_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_suspend':
            wt_patient_suspend_chatNum = data['num']
            wt_patient_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_official':
            wt_official_chatNum = data['num']
            wt_official_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_statistics':
            wt_statistics_chatNum = data['num']
            wt_statistics_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_sms':
            wt_sms_chatNum = data['num']
            wt_sms_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_home_suspend':
            wt_patient_home_suspend_chatNum = data['num']
            wt_patient_home_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_mine_suspend':
            wt_patient_mine_suspend_chatNum = data['num']
            wt_patient_mine_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_evaluation_records_banner':
            wt_patient_evaluation_records_banner_chatNum = data['num']
            wt_patient_evaluation_records_banner_chatTimes = data['times']
        if data['bizType'] == 'ehis' and data['bizScene'] == 'ehis_banner':
            ehis_banner_chatNum = data['num']
            ehis_banner_chatTimes = data['times']
        if data['bizScene'] == 'other':
            other_chatNum = data['num']
            other_chatTimes = data['times']

    # -----------------------------------------
    yesterdayAndBeforeData = content['data']['chatAllInfo']
    for data in yesterdayAndBeforeData:
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_doctor_banner':
            all_wt_doctor_banner_chatNum = data['num']
            all_wt_doctor_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_banner':
            all_wt_patient_banner_chatNum = data['num']
            all_wt_patient_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_suspend':
            all_wt_patient_suspend_chatNum = data['num']
            all_wt_patient_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_official':
            all_wt_official_chatNum = data['num']
            all_wt_official_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_statistics':
            all_wt_statistics_chatNum = data['num']
            all_wt_statistics_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_sms':
            all_wt_sms_chatNum = data['num']
            all_wt_sms_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_home_suspend':
            all_wt_patient_home_suspend_chatNum = data['num']
            all_wt_patient_home_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_mine_suspend':
            all_wt_patient_mine_suspend_chatNum = data['num']
            all_wt_patient_mine_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_evaluation_records_banner':
            all_wt_patient_evaluation_records_banner_chatNum = data['num']
            all_wt_patient_evaluation_records_banner_chatTimes = data['times']
        if data['bizType'] == 'ehis' and data['bizScene'] == 'ehis_banner':
            all_ehis_banner_chatNum = data['num']
            all_ehis_banner_chatTimes = data['times']
        if data['bizScene'] == 'other':
            all_other_chatNum = data['num']
            all_other_chatTimes = data['times']

    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n"
                    f"项目描述：{description}\n"
                    f"数据单位：问答人数/问答次数\n"
                    f"============================\n"
                    f"{Getdate().getYesterday()}数据\n"
                    f"梧桐:\n"
                    f"-AI小梧:\n"
                    f"--pc端小梧：{wt_statistics_chatNum}/{wt_statistics_chatTimes}\n"
                    f"--盛源公众号：{wt_official_chatNum}/{wt_official_chatTimes}\n"
                    f"--用户小程序banner：{wt_patient_banner_chatNum}/{wt_patient_banner_chatTimes}\n"
                    f"--用户小程序icon：{wt_patient_suspend_chatNum}/{wt_patient_suspend_chatTimes}\n"
                    f"--专家小程序banner：{wt_doctor_banner_chatNum}/{wt_doctor_banner_chatTimes}\n"
                    f"--小程序短链：{wt_sms_chatNum}/{wt_sms_chatTimes}\n"
                    f"互联网医院:\n"
                    f"-AI小梧:\n"
                    f"--互联网用户小程序banner：{ehis_banner_chatNum}/{ehis_banner_chatTimes}\n"
                    f"============================\n"
                    f"{Getdate().getYesterday()}(含)之前数据\n"
                    f"梧桐:\n"
                    f"-AI小梧:\n"
                    f"--pc端小梧：{all_wt_statistics_chatNum}/{all_wt_statistics_chatTimes}\n"
                    f"--盛源公众号：{all_wt_official_chatNum}/{all_wt_official_chatTimes}\n"
                    f"--用户小程序banner：{all_wt_patient_banner_chatNum}/{all_wt_patient_banner_chatTimes}\n"
                    f"--用户小程序icon：{all_wt_patient_suspend_chatNum}/{all_wt_patient_suspend_chatTimes}\n"
                    f"--专家小程序banner：{all_wt_doctor_banner_chatNum}/{all_wt_doctor_banner_chatTimes}\n"
                    f"--小程序短链：{all_wt_sms_chatNum}/{all_wt_sms_chatTimes}\n"
                    f"互联网医院：\n"
                    f"-AI小梧:\n"
                    f"--互联网用户小程序banner：{all_ehis_banner_chatNum}/{all_ehis_banner_chatTimes}\n"
        }
    }
    return message_content


def generate_message_content_AiRobot_1(content, description, report_url):
    '''
    AI小梧各系统的点击人数/点击次数
    数据统计为t-1
    维度为：t-1当日新增，t-1及其之前的所有数据
    '''
    # 字段命名
    wt_doctor_banner_chatNum = 0
    wt_doctor_banner_chatTimes = 0
    wt_patient_banner_chatNum = 0
    wt_patient_banner_chatTimes = 0
    wt_patient_suspend_chatNum = 0
    wt_patient_suspend_chatTimes = 0
    wt_official_chatNum = 0
    wt_official_chatTimes = 0
    wt_statistics_chatNum = 0
    wt_statistics_chatTimes = 0
    wt_sms_chatNum = 0
    wt_sms_chatTimes = 0
    wt_patient_home_suspend_chatNum = 0
    wt_patient_home_suspend_chatTimes = 0
    wt_patient_mine_suspend_chatNum = 0
    wt_patient_mine_suspend_chatTimes = 0
    wt_patient_evaluation_records_banner_chatNum = 0
    wt_patient_evaluation_records_banner_chatTimes = 0
    ehis_banner_chatNum = 0
    ehis_banner_chatTimes = 0
    other_chatNum = 0
    other_chatTimes = 0

    all_wt_doctor_banner_chatNum = 0
    all_wt_doctor_banner_chatTimes = 0
    all_wt_patient_banner_chatNum = 0
    all_wt_patient_banner_chatTimes = 0
    all_wt_patient_suspend_chatNum = 0
    all_wt_patient_suspend_chatTimes = 0
    all_wt_official_chatNum = 0
    all_wt_official_chatTimes = 0
    all_wt_statistics_chatNum = 0
    all_wt_statistics_chatTimes = 0
    all_wt_sms_chatNum = 0
    all_wt_sms_chatTimes = 0
    all_wt_patient_home_suspend_chatNum = 0
    all_wt_patient_home_suspend_chatTimes = 0
    all_wt_patient_mine_suspend_chatNum = 0
    all_wt_patient_mine_suspend_chatTimes = 0
    all_wt_patient_evaluation_records_banner_chatNum = 0
    all_wt_patient_evaluation_records_banner_chatTimes = 0
    all_ehis_banner_chatNum = 0
    all_ehis_banner_chatTimes = 0
    all_other_chatNum = 0
    all_other_chatTimes = 0

    yesterdayData = content['data']['pvInfo']
    for data in yesterdayData:
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_doctor_banner':
            wt_doctor_banner_chatNum = data['num']
            wt_doctor_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_banner':
            wt_patient_banner_chatNum = data['num']
            wt_patient_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_suspend':
            wt_patient_suspend_chatNum = data['num']
            wt_patient_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_official':
            wt_official_chatNum = data['num']
            wt_official_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_statistics':
            wt_statistics_chatNum = data['num']
            wt_statistics_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_sms':
            wt_sms_chatNum = data['num']
            wt_sms_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_home_suspend':
            wt_patient_home_suspend_chatNum = data['num']
            wt_patient_home_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_mine_suspend':
            wt_patient_mine_suspend_chatNum = data['num']
            wt_patient_mine_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_evaluation_records_banner':
            wt_patient_evaluation_records_banner_chatNum = data['num']
            wt_patient_evaluation_records_banner_chatTimes = data['times']
        if data['bizType'] == 'ehis' and data['bizScene'] == 'ehis_banner':
            ehis_banner_chatNum = data['num']
            ehis_banner_chatTimes = data['times']
        if data['bizScene'] == 'other':
            other_chatNum = data['num']
            other_chatTimes = data['times']

    # -----------------------------------------
    yesterdayAndBeforeData = content['data']['pvAllInfo']
    for data in yesterdayAndBeforeData:
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_doctor_banner':
            all_wt_doctor_banner_chatNum = data['num']
            all_wt_doctor_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_banner':
            all_wt_patient_banner_chatNum = data['num']
            all_wt_patient_banner_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_suspend':
            all_wt_patient_suspend_chatNum = data['num']
            all_wt_patient_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_official':
            all_wt_official_chatNum = data['num']
            all_wt_official_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_statistics':
            all_wt_statistics_chatNum = data['num']
            all_wt_statistics_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_sms':
            all_wt_sms_chatNum = data['num']
            all_wt_sms_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_home_suspend':
            all_wt_patient_home_suspend_chatNum = data['num']
            all_wt_patient_home_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_mine_suspend':
            all_wt_patient_mine_suspend_chatNum = data['num']
            all_wt_patient_mine_suspend_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_evaluation_records_banner':
            all_wt_patient_evaluation_records_banner_chatNum = data['num']
            all_wt_patient_evaluation_records_banner_chatTimes = data['times']
        if data['bizType'] == 'ehis' and data['bizScene'] == 'ehis_banner':
            all_ehis_banner_chatNum = data['num']
            all_ehis_banner_chatTimes = data['times']
        if data['bizScene'] == 'other':
            all_other_chatNum = data['num']
            all_other_chatTimes = data['times']

    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n"
                    f"项目描述：{description}\n"
                    f"数据单位：点击人数/点击次数\n"
                    f"============================\n"
                    f"{Getdate().getYesterday()}数据\n"
                    f"梧桐:\n"
                    f"-AI小梧:\n"
                    f"--盛源公众号：{wt_official_chatNum}/{wt_official_chatTimes}\n"
                    f"--用户小程序banner：{wt_patient_banner_chatNum}/{wt_patient_banner_chatTimes}\n"
                    f"--用户小程序icon：{wt_patient_suspend_chatNum}/{wt_patient_suspend_chatTimes}\n"
                    f"--专家小程序banner：{wt_doctor_banner_chatNum}/{wt_doctor_banner_chatTimes}\n"
                    f"--小程序短链：{wt_sms_chatNum}/{wt_sms_chatTimes}\n"
                    f"-AI营养师:\n"
                    f"--用户小程序首页浮窗：{wt_patient_home_suspend_chatNum}/{wt_patient_home_suspend_chatTimes}\n"
                    f"--用户小程序我的页浮窗：{wt_patient_mine_suspend_chatNum}/{wt_patient_mine_suspend_chatTimes}\n"
                    f"--测评记录页面banner：{wt_patient_evaluation_records_banner_chatNum}/{wt_patient_evaluation_records_banner_chatTimes}\n"
                    f"互联网医院:\n"
                    f"-AI小梧:\n"
                    f"--互联网用户小程序banner：{ehis_banner_chatNum}/{ehis_banner_chatTimes}\n"
                    f"============================\n"
                    f"{Getdate().getYesterday()}(含)之前数据\n"
                    f"梧桐:\n"
                    f"-AI小梧:\n"
                    f"--盛源公众号：{all_wt_official_chatNum}/{all_wt_official_chatTimes}\n"
                    f"--用户小程序banner：{all_wt_patient_banner_chatNum}/{all_wt_patient_banner_chatTimes}\n"
                    f"--用户小程序icon：{all_wt_patient_suspend_chatNum}/{all_wt_patient_suspend_chatTimes}\n"
                    f"--专家小程序banner：{all_wt_doctor_banner_chatNum}/{all_wt_doctor_banner_chatTimes}\n"
                    f"--小程序短链：{all_wt_sms_chatNum}/{all_wt_sms_chatTimes}\n"
                    f"-AI营养师:\n"
                    f"--用户小程序首页浮窗：{all_wt_patient_home_suspend_chatNum}/{all_wt_patient_home_suspend_chatTimes}\n"
                    f"--用户小程序我的页浮窗：{all_wt_patient_mine_suspend_chatNum}/{all_wt_patient_mine_suspend_chatTimes}\n"
                    f"--测评记录页面banner：{all_wt_patient_evaluation_records_banner_chatNum}/{all_wt_patient_evaluation_records_banner_chatTimes}\n"
                    f"互联网医院：\n"
                    f"-AI小梧:\n"
                    f"--互联网用户小程序banner：{all_ehis_banner_chatNum}/{all_ehis_banner_chatTimes}\n"
        }
    }
    return message_content


def generate_message_content_AiRobot_2(content, description, report_url):
    '''
    1、AI小梧点击人数/点击次数
    2、数据统计为t-1
    3、维度为：t-1当日新增，t-1及其之前的所有数据
    4、wt_patient_home_suspend_3 梧桐小程序首页浮窗 (ai小梧 3.0)
    5、wt_patient_mine_suspend_3 梧桐小程序我的页面浮窗 (ai小梧 3.0)
    6、wt_patient_add_baby 梧桐小程序添加宝贝 (ai小梧 3.0)
    7、wt_patient_account 梧桐公众号（ai小梧 3.0）
    '''
    # ==============昨日新增数据==================
    wt_patient_home_suspend_3_chatNum = 0
    wt_patient_home_suspend_3_chatTimes = 0
    wt_patient_mine_suspend_3_chatNum = 0
    wt_patient_mine_suspend_3_chatTimes = 0
    wt_patient_add_baby_chatNum = 0
    wt_patient_add_baby_chatTimes = 0
    wt_patient_account_chatNum = 0
    wt_patient_account_chatTimes = 0

    # ===========历史数据==============
    all_wt_patient_home_suspend_3_chatNum = 0
    all_wt_patient_home_suspend_3_chatTimes = 0
    all_wt_patient_mine_suspend_3_chatNum = 0
    all_wt_patient_mine_suspend_3_chatTimes = 0
    all_wt_patient_add_baby_chatNum = 0
    all_wt_patient_add_baby_chatTimes = 0
    all_wt_patient_account_chatNum = 0
    all_wt_patient_account_chatTimes = 0

    # ---------------昨日新增数据--------------------------
    yesterdayData = content['data']['pvInfo']
    for data in yesterdayData:
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_home_suspend_3': # 梧桐小程序首页浮窗
            wt_patient_home_suspend_3_chatNum = data['num']
            wt_patient_home_suspend_3_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_mine_suspend_3': # 梧桐小程序我的页面
            wt_patient_mine_suspend_3_chatNum = data['num']
            wt_patient_mine_suspend_3_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_add_baby': # 梧桐小程序添加宝贝
            wt_patient_add_baby_chatNum = data['num']
            wt_patient_add_baby_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_account': # 盛源公众号
            wt_patient_account_chatNum = data['num']
            wt_patient_account_chatTimes = data['times']

    # ---------------历史数据--------------------------
    yesterdayAndBeforeData = content['data']['pvAllInfo']
    for data in yesterdayAndBeforeData:
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_home_suspend_3':  # 梧桐小程序首页浮窗
            all_wt_patient_home_suspend_3_chatNum = data['num']
            all_wt_patient_home_suspend_3_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_mine_suspend_3': # 梧桐小程序我的页面
            all_wt_patient_mine_suspend_3_chatNum = data['num']
            all_wt_patient_mine_suspend_3_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_add_baby': # 梧桐小程序添加宝贝
            all_wt_patient_add_baby_chatNum = data['num']
            all_wt_patient_add_baby_chatTimes = data['times']
        if data['bizType'] == 'wutong' and data['bizScene'] == 'wt_patient_account': # 盛源公众号
            all_wt_patient_account_chatNum = data['num']
            all_wt_patient_account_chatTimes = data['times']

    message_content = {
        "msg_type": "text",
        "content": {
            "text": f"自动化执行结果：\n"
                    f"项目描述：{description}\n"
                    f"统计维度：点击人数/点击次数\n"
                    f"          \n"
                    f"{Getdate().getYesterday()}新增数据\n"
                    f"盛源公众号：{wt_patient_account_chatNum}/{wt_patient_account_chatTimes}\n"
                    f"小程序首页浮窗：{wt_patient_home_suspend_3_chatNum}/{wt_patient_home_suspend_3_chatTimes}\n"
                    f"小程序我的页面浮窗：{wt_patient_mine_suspend_3_chatNum}/{wt_patient_mine_suspend_3_chatTimes}\n"
                    f"用户添加宝贝跳转：{wt_patient_add_baby_chatNum}/{wt_patient_add_baby_chatTimes}\n"
                    f"          \n"
                    f"历史数据汇总\n"
                    f"盛源公众号：{all_wt_patient_account_chatNum}/{all_wt_patient_account_chatTimes}\n"
                    f"小程序首页浮窗：{all_wt_patient_home_suspend_3_chatNum}/{all_wt_patient_home_suspend_3_chatTimes}\n"
                    f"小程序我的页面浮窗：{all_wt_patient_mine_suspend_3_chatNum}/{all_wt_patient_mine_suspend_3_chatTimes}\n"
                    f"用户添加宝贝跳转：{all_wt_patient_add_baby_chatNum}/{all_wt_patient_add_baby_chatTimes}\n"
        }
    }
    return message_content


def generate_message_content_AI_XIAOWU(content, description, report_url, ai_report_url):
    # AI小梧3天内的统计数据
    # message_content_text = {
    #     "msg_type": "text",
    #     "content": {
    #         "text": f"自动化执行结果：\n"
    #                 f"项目描述：{description}\n"
    #                 f"          \n"
    #                 f"{Getdate().getYesterday()}数据\n"
    #                 f"新增用户数：{content['yesterday']['accountNum']}\n"
    #                 f"新增宝贝数：{content['yesterday']['childrenNum']}\n"
    #                 f"进小梧聊天页宝贝数：{content['yesterday']['chatBabyNum']}\n"
    #                 f"点击测量报告宝贝数：{content['yesterday']['cardUserNum']}\n"
    #                 f"主动提问宝贝数：{content['yesterday']['askQuestionBabyNum']}\n"
    #                 f"          \n"
    #                 f"{Getdate().getDayBeforeYesterday()}数据\n"
    #                 f"新增用户数：{content['beforeYesterday']['accountNum']}\n"
    #                 f"新增宝贝数：{content['beforeYesterday']['childrenNum']}\n"
    #                 f"进小梧聊天页宝贝数：{content['beforeYesterday']['chatBabyNum']}\n"
    #                 f"点击测量报告宝贝数：{content['beforeYesterday']['cardUserNum']}\n"
    #                 f"主动提问宝贝数：{content['beforeYesterday']['askQuestionBabyNum']}\n"
    #                 f"          \n"
    #                 f"{Getdate().getThreeDaysAgo()}数据\n"
    #                 f"新增用户数：{content['3DayAgo']['accountNum']}\n"
    #                 f"新增宝贝数：{content['3DayAgo']['childrenNum']}\n"
    #                 f"进小梧聊天页宝贝数：{content['3DayAgo']['chatBabyNum']}\n"
    #                 f"点击测量报告宝贝数：{content['3DayAgo']['cardUserNum']}\n"
    #                 f"主动提问宝贝数：{content['3DayAgo']['askQuestionBabyNum']}\n"
    #                 f"          \n"
    #                 f"详细数据=>[Excel]({ai_report_url})\n"
    #
    #     }
    # }
    message_content = {
        "msg_type": "post",
        "content": {
            "post": {
                "zh_cn": {
                    "title": f"{description}",
                    "content": [
                        [
                            {"tag": "text", "text": f"{Getdate().getYesterday()}"},
                        ],
                        [
                            {"tag": "text", "text": f"新增用户数：{content['yesterday']['accountNum']}"}
                        ],
                        [
                            {"tag": "text", "text": f"新增宝贝数：{content['yesterday']['childrenNum']}"}
                        ],
                        [
                            {"tag": "text", "text": f"进小梧聊天数：{content['yesterday']['chatBabyNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"点击测量报告数：{content['yesterday']['cardUserNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"主动提问数：{content['yesterday']['askQuestionBabyNum']}"},
                        ],
                        [],
                        [
                            {"tag": "text", "text": f"{Getdate().getDayBeforeYesterday()}"},
                        ],
                        [
                            {"tag": "text", "text": f"新增用户数：{content['beforeYesterday']['accountNum']}"}
                        ],
                        [
                            {"tag": "text", "text": f"新增宝贝数：{content['beforeYesterday']['childrenNum']}"}
                        ],
                        [
                            {"tag": "text", "text": f"进小梧聊天数：{content['beforeYesterday']['chatBabyNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"点击测量报告数：{content['beforeYesterday']['cardUserNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"主动提问数：{content['beforeYesterday']['askQuestionBabyNum']}"},
                        ],
                        [],
                        [
                            {"tag": "text", "text": f"{Getdate().getThreeDaysAgo()}"},
                        ],
                        [
                            {"tag": "text", "text": f"新增用户数：{content['3DayAgo']['accountNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"新增宝贝数：{content['3DayAgo']['childrenNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"进小梧聊天数：{content['3DayAgo']['chatBabyNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"点击测量报告数：{content['3DayAgo']['cardUserNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"主动提问数：{content['3DayAgo']['askQuestionBabyNum']}"},
                        ],
                        [],
                        [
                            {"tag": "text", "text": f"历史进入AI≥2次的人数：{content['history']['repeatCenterUserNum']}"},
                        ],
                        [
                            {"tag": "text", "text": f"历史产生会话≥2的人数：{content['history']['repeatConversationUserNum']}"},
                        ],
                        [],
                        [
                            {"tag": "a", "text": "更多数据 => 点击下载 Excel", "href": ai_report_url}
                        ]
                    ]
                }
            }
        }
    }
    return message_content

if __name__ == '__main__':
    # push_message('https://open.feishu.cn/open-apis/bot/v2/hook/54561cfd-7d1d-4102-98bd-23aecd528345',
    #              generate_message_content_AiRobot_1(
    #                  parse_prometheus_data(config_variable_path),
    #                              'AI使用统计', 'http://localhost'))

    push_message('https://open.feishu.cn/open-apis/bot/v2/hook/1af3c7c7-91bc-45ee-95f9-616c5e8f982d',
                 generate_message_content_AI_XIAOWU(
                     parse_prometheus_data(config_variable_path),
                     'AI小吴统计数据', 'http://localhost','http://'))
